package com.example.demo.controller;

import com.example.demo.core.StandardResult;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 基类
 */

@ApiIgnore
public class BaseController {

    public StandardResult success(Object data){
        StandardResult standardResult = new StandardResult();
        standardResult.setCode("0");
        standardResult.setMsg("操作成功");
        standardResult.setData(data);

        return  standardResult;
    }

    public  StandardResult success() {
        return success(null);
    }

    public static StandardResult error(String code, String msg) {
        StandardResult standardResult = new StandardResult();
        standardResult.setCode(code);
        standardResult.setMsg(msg);

        return  standardResult;
    }

    public static StandardResult error(String code) {
        StandardResult standardResult = new StandardResult();
        standardResult.setCode(code);
        standardResult.setMsg("操作失败");

        return  standardResult;
    }
}


